<script>
export default {
  name: "Info",
  props: {
    data: {
      type: Array,
      default: () => [],
    },
  },
  computed: {
    item() {
      return this.data[0];
    },
  },
  methods: {
    getContentChild(content, key) {
      return content[key] && content[key].length > 0;
    },
  },
};
</script>

<template>
  <div v-if="item" class="accountInfo-box">
    <JSONText :item="data"></JSONText>
    <div class="head">
      <ImagePreview
        :imageStyle="{ width: '54px', height: '54px' }"
        :src="item.avatar"
        class="avatar"
      ></ImagePreview>
      <div class="info">
        <div class="head-nickName">{{ item.userName }}</div>
        <div class="head-qqNum">{{ item.accountName }}</div>
      </div>
    </div>
    <div class="content">
      <div v-for="(item, index) in item.detail" class="content-item">
        <span class="content-label">{{ item.label }}</span>
        <span class="content-value">{{ item.value }}</span>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.accountInfo-box {
  width: 800px;
}

.accountInfo-box {
  $bg-color-1: #15465f;
  $font-color-1: #5ae1fe;
  $font-color-2: #ffffff;
  $font-color-3: #666666;

  .head {
    background-color: #f1f1f1;
    border-radius: 5px;
    padding: 10px;

    display: flex;
    margin-bottom: 16px;

    .avatar {
      width: 54px;
      height: 54px;
      margin-right: 16px;
      border-radius: 5px;
    }

    .info {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      flex: 1;
      padding: 0px 0px 8px 0px;

      .head-nickName {
        lin-height: 28px;
        font-size: 16px;
        //color: $font-color-2;
        display: flex;
        align-items: center;

        .head-tag {
          flex: 1;
          width: 0;
          display: flex;
          flex-wrap: wrap;
          margin-bottom: -8px;

          .tag-item {
            border-radius: 4px;
            margin-bottom: 8px;
            margin-left: 8px;
            border: 1px solid #dfa35a;
            color: #dfa35a;
            font-size: 14px;
            background-color: #2e4d56;
            padding: 4px 7px;
          }
        }
      }

      .head-qqNum {
        font-size: 14px;
        color: #666666;
      }
    }
  }

  .content {
    padding-left: 10px;
    font-size: 16px;

    .content-item {
      margin-bottom: 8px;

      &:last-child {
        margin-bottom: 0px;
      }

      .content-label {
        display: inline-block;
        width: 120px;
        vertical-align: baseline;
        color: #666666;
      }

      .content-value {
        max-width: calc(100% - 140px);
        overflow: hidden;
        text-overflow: ellipsis;
        vertical-align: top;
        white-space: nowrap;
        display: inline-block;
        //color: #c6cfd5;
      }
    }
  }
}
</style>
